package com.java.tutorials.jdk7.fileattribute;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.DosFileAttributeView;
/**
 * Created by xuzhike on 2016/1/24.
 * http://www.java2s.com/Code/Java/JDK-7/FilemetadataandDosFileAttributeView.htm
 * File metadata and DosFileAttributeView
 */
public class DosFileAttributeViewTest {
    public static void main(String[] args) throws Exception{
        Path path = FileSystems.getDefault().getPath("e:/yjbWechat.txt");
        System.out.println("File Size:" + Files.size(path));
        System.out.println("Is Directory:" + Files.isDirectory(path));
        System.out.println("Is Regular File:" + Files.isRegularFile(path));
        System.out.println("Is Symbolic Link:" + Files.isSymbolicLink(path));
        System.out.println("Is Hidden:" + Files.isHidden(path));
        System.out.println("Last Modified Time:" + Files.getLastModifiedTime(path));
        System.out.println("Owner:" + Files.getOwner(path));

        DosFileAttributeView view = Files.getFileAttributeView(path,
                DosFileAttributeView.class);
        System.out.println("Archive  :" + view.readAttributes().isArchive());
        System.out.println("Hidden   :" + view.readAttributes().isHidden());
        System.out.println("Read-only:" + view.readAttributes().isReadOnly());
        System.out.println("System   :" + view.readAttributes().isSystem());

        view.setHidden(false);
    }
}
